package myServer;

import java.io.*;
import java.net.*;

public class MyClient {

    Socket s;
    private static String SERVER = "localhost";
    private static int PORT = 8189;
    String input = "";

    MyClient() {
        try {
            s = new Socket();
            s.connect(new InetSocketAddress(SERVER, PORT));

            BufferedReader s_in = new BufferedReader(new InputStreamReader(s.getInputStream()));
            PrintWriter s_out = new PrintWriter(s.getOutputStream(), true /* autoFlush */);

            BufferedReader console = new BufferedReader(new InputStreamReader(System.in));

            String data = s_in.readLine();

            System.out.println("Received:" + data);

            do {
                input = console.readLine();
                s_out.println(input);
                data = s_in.readLine();
                System.out.println("Received:" + data);
            } while (!input.equals("BYE"));

        } catch (IOException ex) {
            System.out.println("IO:" + ex.getMessage());
        }
    }

    public static void main(String args[]) {
        MyClient c = new MyClient();
    }
}
